<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>后台模板SpringbootDemo版本</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
        <link rel="stylesheet" href="/static/css/xadmin.css">
        <link rel="stylesheet" href="/static/ztree/css/metroStyle/metroStyle.css">
        <script src="/static/js/jquery.min.js" charset="utf-8"></script>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/static/js/ztree.js" charset="utf-8"></script>
        <script src="/static/js/excheck.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
    </head>
    <body>


        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <input type="hidden" id="menuId" th:value="${menu.id}"/>
                    <div class="layui-form-item">
                        <label for="parentMenu" class="layui-form-label">
                            上级菜单
                        </label>
                        <div class="layui-input-inline" >
                          <input type="text" id="parentMenu" name="parentMenu" required="" th:value="${menu.parentMenu}" readonly="readonly"
                                   autocomplete="off" class="layui-input">
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label for="menuName" class="layui-form-label">
                            <span class="x-red">*</span>菜单名称
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="menuName" name="menuName" required="" lay-verify="required" th:value="${menu.menuName}"
                                   autocomplete="off" class="layui-input">
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label for="menuUrl" class="layui-form-label">
                            <span class="x-red">*</span>请求Url
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="menuUrl" name="menuUrl" required="" lay-verify="required" th:value="${menu.menuUrl}"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button  class="layui-btn" lay-filter="add" lay-submit="" style="margin-left: 111px;">
                            提交
                        </button>
                    </div>
                </form>
            </div>
        </div>
        <script>
            var setting = {
                check: {
                    enable: true
                },
                data: {
                    simpleData: {
                        enable: true
                    }
                }
            };



            var zNodes = [
                {name: "父节点1", children: [
                        {name: "子节点1"},
                        {name: "子节点2"}
                    ]}
            ];
            $(document).ready(function(){
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            });
            layui.use(['form', 'layer'],
               function() {
                    $ = layui.jquery;
                    var form = layui.form,
                    layer = layui.layer;
                    //监听提交
                    form.on('submit(add)',function(data){
                        var id = $("#menuId").val();
                        $.post(
                            '/system/menu/update',
                            {
                                "id":id,
                                "menuName" : data.field.menuName,
                                "menuUrl" : data.field.menuUrl
                            },
                            function(result){
                                  if(result.code == 0){
                                      layer.alert("修改成功",{icon:6},function(){
                                          //关闭当前frame
                                          xadmin.close();
                                          // 可以对父窗口进行刷新
                                          xadmin.father_reload();
                                      });

                                  }
                            },
                            'json'
                        );
                        return false;
                    });




            });
        </script>

    </body>

</html>
